<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arrays=["sss","唐玮"];
        let name=["sb","sasa"];
        arrays.push(...name);//将数组展开，加入到arrays里面
        console.table(arrays);

        //数组截断
         let arr=[12,15,47,65];
        let arr2= arr.slice(0,2);//0到2，2不取
         console.log(arr2);//[12,15]
         console.log(arr);//原数组不受影响
         console.log("______________________");

         //splice,原数组会改变
         
         let arr3=[123,56,48,23,"唐玮"];
        //  let arr33=arr3.splice(1,2)//后面的是数量
        //  console.log(arr33);//[56, 48]
        //  console.log(arr3);//数组变化了 [123, 23, '唐玮']
       
        //还可以替换元素
        let arr33=arr3.splice(1,2,"sssss",250);
        console.log(arr3);//[123, 'sssss', 250, 23, '唐玮']
        
        //向中间增加
        let array1=[1,2,3,4,5,6];
        array1.splice(1,0,"唐玮","sb");//在序号1的前面无限追加元素
        console.log(array1);
        //末尾追加元素
        array1.splice(array1.length,0,"末尾元素");
        console.log(array1);
        //或者直接用push
        array1.push("hhhhhh");
        console.table(array1)
   
   //数组元素的复制
   let arrayss=[1,2,3,4,5,6];
   arrayss.copyWithin(0,4,6);//[5, 6, 3, 4, 5, 6] 后面的序号6去不到
          //copyWithin(target, start, end)
   console.log(arrayss);
   </script>
</body>
</html>